﻿using System;
using Unis.Framework.ORM.BaseDefiniens.Enums;

namespace Unis.Framework.ORM.Attributes
{
    [AttributeUsage(AttributeTargets.Class)]
    public class ModelMapAttribute : Attribute
    {
        // Properties
        public ModelConfigOptions ConfigOptions { get; set; }

        public string[] PrimaryKeys { get; set; }

        public string TableName { get; set; }

        public string XmlFileName { get; set; }

        #region Constructs
        /// <summary>
        ///  实体类与XML文件映射的特性
        /// </summary>
        /// <param name="xmlFileName">XML文件名称</param>
        /// <param name="primaryKey">对应表的主键</param>
        public ModelMapAttribute(string xmlFileName, string primaryKey)
            : this("", xmlFileName, ModelConfigOptions.None, primaryKey)
        {
            
        }

        public ModelMapAttribute(string tableName, params string[] primaryKeys)
            : this(tableName, tableName, primaryKeys)
        {
        }

        public ModelMapAttribute(string tableName, string xmlFileName, params string[] primaryKeys)
            : this(tableName, xmlFileName, ModelConfigOptions.CreateSqlByXmlCfg | ModelConfigOptions.ColumnCfgByAttribute, primaryKeys)
        {
        }

        public ModelMapAttribute(string tableName, string xmlFileName, ModelConfigOptions configOptions, params string[] primaryKeys)
        {
            this.TableName = tableName;
            this.XmlFileName = xmlFileName;
            this.PrimaryKeys = primaryKeys;
            this.ConfigOptions = configOptions;
        }

        #endregion
    }
}
